package com.dragon7531.bdemo.domain;

import com.dragon7531.bdemo.validate.InsertValidateGroup;
import com.dragon7531.bdemo.validate.UpdateValidateGroup;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

public class Student implements Serializable {

    @NotNull(message = "id不能为空",groups = {UpdateValidateGroup.class})
    private Integer id;

    @NotBlank(message = "姓名不能为空")
    @Length(min = 2,max = 19,message="姓名长度2~19")
    private String name;
    @NotNull(message = "年龄不能为空")
    @Range(min=3,max = 150,message = "年龄应大于3岁小于150岁")
//    @Min(value = 3, message = "年龄应大于3岁")
//    @Max(value = 150, message = "年龄应小于150岁")
    private Integer age;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", name=").append(name);
        sb.append(", age=").append(age);
        sb.append("]");
        return sb.toString();
    }
}
